Error detection
===============

Checksum
--------
* Uses ones complement. (A carryout from the most significant bit needs to be added to the result.)
* 16-bit checksum

CRC
---
* Uses CRC-32. (A division polynomial of degree 32: $1 + \sum_{n=1}^{32} a_n x^n$)
* Actually sends (n+k)-bit message when a message of length n needs to be transmitted.
* The minus operation in polynomial arithmetic is the logical XOR operation.


Reliable transmission
=====================

ACK, timeout, ARQ

Stop-and-Wait
-------------

* A subtlety in the stop-and-wait algorithm:
> The sender sends a frame and the receiver acknowledges it, 
> but the acknowledgment is either lost or delayed in arriving.
>
> The sender times out and retransmits the original frame, 
> but the receiver will think that it is the next frame.
_Solution_: Including 1-bit sequence number in the header.

* The main shortcoming
One outstanding frame on the link at a time
> _Example_: 
> 1.5-Mbps link with a 45-ms RTT: delay×bandwidth = 8KB, frame size = 1 KB
> Maximum sending rate = Bits Per Frame ÷ Time Per Frame = 1024 * 8 / 0.045 = 182 kbps (about 1/8 of the link's capacity)

Sliding Window
--------------

LFS − LAR ≤ SWS (last frame sent - last acknowledgment received = send window size)

LAF − LFR ≤ RWS (largest acceptable frame - last frame received = receive window size)

_Note_: It makes no sense to set RWS > SWS.

_Finite Sequence Numbers_: 

1. Sender sends frames 0 to (n-1) to Receiver
2. Receiver receives frames 0 to (n-1)
3. Receiver sends  for frames 0 to (n-1), and slides its window
4. Acknowledgments are lost
5. Sender times out, sends frames 0 to (n-1) again

Obviously the new sequence numbers in Receiver's current sliding window should not contain any number from 0 to (n-1). Hence,  
SWS ≤ MaxSeqNum / 2, if MaxSeqNum is even  
SWS < (MaxSeqNum + 1) / 2, if MaxSeqNum is odd  

which can be written as:
SWS < (MaxSeqNum + 1) / 2


Ethernet
========

Physical Properties
-------------------

* Uses coaxial cable of length up to 500m
	[ Host (Adaptor) ]
	           |
	           V
	=======Transceiver======(Ethernet cable)====
* No more than 4 repeaters (a total reach of only 2500m)
* Hub (multiway repeater)

Frame Format
------------

frame = 64-bit Preamble + 14-byte header from the host’s perspective 
+ Body + 32-bit CRC

14-byte header = 48-bit Dest addr + 48-bit Src addr + 16-bit Type


Minimum Frame Size
------------------

2500m / (2 * 10^8 m/s) * 2 = 25us;
25us + repeater delay = 51.2us
51.2us * 10Mbps = 512 bits = 64 B;
64 B - 18 B = 46 B
